//
//  Lottery.swift
//  MakeMoney
//
//  Created by Fan ZhiQiang on 2024/12/6.
//

import Observation
import Foundation

@Observable class Lottery: Identifiable, Codable {
    enum CodingKeys: String, CodingKey {
        case _date = "date"
        case _dateStr = "dateStr"
        case _front1 = "front1"
        case _front2 = "front2"
        case _front3 = "front3"
        case _front4 = "front4"
        case _front5 = "front5"
        case _hind1 = "hind1"
        case _hind2 = "hind2"
        case _id = "id"
        case _lotteryBall = "lotteryBall"
        case _type = "type"
        case _typeAverage = "typeAverage"
        case _yearId = "yearId"
        case _zAverage = "zAverage"
        case _zAverageGap = "zAverageGap"
        case _zMinus = "zMinus"
        case _zStatistic = "zStatistic"
        case _zSum = "zSum"
    }
    var date: Date         //时间戳
    var dateStr: String
    var front1: Int
    var front2: Int
    var front3: Int
    var front4: Int
    var front5: Int
    var hind1: Int
    var hind2: Int
    var id: Int
    var lotteryBall: Int
    var type: String
    var typeAverage: String
    var yearId: Int
    var zAverage: LotteryAverage
    var zAverageGap: LotteryAverageGap
    var zMinus: LotteryMinus
    var zStatistic: LotteryStatistic
    var zSum: LotterySum
}

extension Lottery: Equatable {
    static func ==(lhs: Lottery, rhs: Lottery) -> Bool {
        lhs.id == rhs.id
    }
}

extension Lottery: Hashable {
    func hash(into hasher: inout Hasher) {
        hasher.combine(id)
    }
}

extension Lottery: Comparable {
    static func <(lhs: Lottery, rhs: Lottery) -> Bool {
        lhs.id > rhs.id
    }
}

@Observable class LotteryAverage: Codable {
    enum CodingKeys: String, CodingKey {
        case _front1 = "front1"
        case _front2 = "front2"
        case _front3 = "front3"
        case _front4 = "front4"
        case _front5 = "front5"
        case _frontArea = "frontArea"
        case _hind1 = "hind1"
        case _hind2 = "hind2"
        case _hindArea = "hindArea"
        case _totalArea = "totalArea"
    }
    var front1: Double
    var front2: Double
    var front3: Double
    var front4: Double
    var front5: Double
    var frontArea: Double
    var hind1: Double
    var hind2: Double
    var hindArea: Double
    var totalArea: Double
}

@Observable class LotteryAverageGap: Codable {
    enum CodingKeys: String, CodingKey {
        case _front1 = "front1"
        case _front2 = "front2"
        case _front3 = "front3"
        case _front4 = "front4"
        case _front5 = "front5"
        case _frontArea = "frontArea"
        case _hind1 = "hind1"
        case _hind2 = "hind2"
        case _hindArea = "hindArea"
        case _totalArea = "totalArea"
    }
    var front1: Double
    var front2: Double
    var front3: Double
    var front4: Double
    var front5: Double
    var frontArea: Double
    var hind1: Double
    var hind2: Double
    var hindArea: Double
    var totalArea: Double
}

@Observable class LotteryMinus: Codable {
    enum CodingKeys: String, CodingKey {
        case _currentMinus21 = "currentMinus21"
        case _currentMinus32 = "currentMinus32"
        case _currentMinus43 = "currentMinus43"
        case _currentMinus54 = "currentMinus54"
        case _currentMinus76 = "currentMinus76"
        case _currentTotal = "currentTotal"
    }
    var currentMinus21: Int
    var currentMinus32: Int
    var currentMinus43: Int
    var currentMinus54: Int
    var currentMinus76: Int
    var currentTotal: Int
}

@Observable class LotterySum: Codable {
    enum CodingKeys: String, CodingKey {
        case _currentFront = "currentFront"
        case _currentHind = "currentHind"
        case _currentTotal = "currentTotal"
        case _front1 = "front1"
        case _front2 = "front2"
        case _front3 = "front3"
        case _front4 = "front4"
        case _front5 = "front5"
        case _frontArea = "frontArea"
        case _hind1 = "hind1"
        case _hind2 = "hind2"
        case _hindArea = "hindArea"
        case _totalArea = "totalArea"
    }
    var currentFront: Int
    var currentHind: Int
    var currentTotal: Int
    var front1: Int
    var front2: Int
    var front3: Int
    var front4: Int
    var front5: Int
    var frontArea: Int
    var hind1: Int
    var hind2: Int
    var hindArea: Int
    var totalArea: Int
}

@Observable class LotteryStatistic: Codable {
    enum CodingKeys: String, CodingKey {
        case _front1 = "front1"
        case _front2 = "front2"
        case _front3 = "front3"
        case _front4 = "front4"
        case _front5 = "front5"
        case _hind1 = "hind1"
        case _hind2 = "hind2"
    }
    var front1: StatisticFront1
    var front2: StatisticFront2
    var front3: StatisticFront3
    var front4: StatisticFront4
    var front5: StatisticFront5
    var hind1: StatisticHind1
    var hind2: StatisticHind2
}

@Observable class StatisticFront1: Codable {
    enum CodingKeys: String, CodingKey {
        case _no01 = "no01"
        case _no02 = "no02"
        case _no03 = "no03"
        case _no04 = "no04"
        case _no05 = "no05"
        case _no06 = "no06"
        case _no07 = "no07"
        case _no08 = "no08"
        case _no09 = "no09"
        case _no10 = "no10"
        case _no11 = "no11"
        case _no12 = "no12"
        case _no13 = "no13"
        case _no14 = "no14"
        case _no15 = "no15"
        case _no16 = "no16"
        case _no17 = "no17"
        case _no18 = "no18"
        case _no19 = "no19"
        case _no20 = "no20"
        case _no21 = "no21"
        case _no22 = "no22"
        case _no23 = "no23"
        case _no24 = "no24"
        case _no25 = "no25"
        case _no26 = "no26"
        case _no27 = "no27"
        case _no28 = "no28"
        case _no29 = "no29"
        case _no30 = "no30"
    }
    var no01: Int
    var no02: Int 
    var no03: Int 
    var no04: Int 
    var no05: Int 
    var no06: Int 
    var no07: Int 
    var no08: Int 
    var no09: Int 
    var no10: Int 
    var no11: Int 
    var no12: Int 
    var no13: Int 
    var no14: Int 
    var no15: Int 
    var no16: Int 
    var no17: Int 
    var no18: Int 
    var no19: Int 
    var no20: Int 
    var no21: Int 
    var no22: Int 
    var no23: Int 
    var no24: Int 
    var no25: Int 
    var no26: Int 
    var no27: Int 
    var no28: Int 
    var no29: Int 
    var no30: Int 
}

@Observable class StatisticFront2: Codable {
    enum CodingKeys: String, CodingKey {
        case _no02 = "no02"
        case _no03 = "no03"
        case _no04 = "no04"
        case _no05 = "no05"
        case _no06 = "no06"
        case _no07 = "no07"
        case _no08 = "no08"
        case _no09 = "no09"
        case _no10 = "no10"
        case _no11 = "no11"
        case _no12 = "no12"
        case _no13 = "no13"
        case _no14 = "no14"
        case _no15 = "no15"
        case _no16 = "no16"
        case _no17 = "no17"
        case _no18 = "no18"
        case _no19 = "no19"
        case _no20 = "no20"
        case _no21 = "no21"
        case _no22 = "no22"
        case _no23 = "no23"
        case _no24 = "no24"
        case _no25 = "no25"
        case _no26 = "no26"
        case _no27 = "no27"
        case _no28 = "no28"
        case _no29 = "no29"
        case _no30 = "no30"
        case _no31 = "no31"
        case _no32 = "no32"
    }
    var no02: Int
    var no03: Int 
    var no04: Int 
    var no05: Int 
    var no06: Int 
    var no07: Int 
    var no08: Int 
    var no09: Int 
    var no10: Int 
    var no11: Int 
    var no12: Int 
    var no13: Int 
    var no14: Int 
    var no15: Int 
    var no16: Int 
    var no17: Int 
    var no18: Int 
    var no19: Int 
    var no20: Int 
    var no21: Int 
    var no22: Int 
    var no23: Int 
    var no24: Int 
    var no25: Int 
    var no26: Int 
    var no27: Int 
    var no28: Int 
    var no29: Int 
    var no30: Int 
    var no31: Int 
    var no32: Int 
}

@Observable class StatisticFront3: Codable {
    enum CodingKeys: String, CodingKey {
        case _no03 = "no03"
        case _no04 = "no04"
        case _no05 = "no05"
        case _no06 = "no06"
        case _no07 = "no07"
        case _no08 = "no08"
        case _no09 = "no09"
        case _no10 = "no10"
        case _no11 = "no11"
        case _no12 = "no12"
        case _no13 = "no13"
        case _no14 = "no14"
        case _no15 = "no15"
        case _no16 = "no16"
        case _no17 = "no17"
        case _no18 = "no18"
        case _no19 = "no19"
        case _no20 = "no20"
        case _no21 = "no21"
        case _no22 = "no22"
        case _no23 = "no23"
        case _no24 = "no24"
        case _no25 = "no25"
        case _no26 = "no26"
        case _no27 = "no27"
        case _no28 = "no28"
        case _no29 = "no29"
        case _no30 = "no30"
        case _no31 = "no31"
        case _no32 = "no32"
        case _no33 = "no33"
    }
    var no03: Int
    var no04: Int 
    var no05: Int 
    var no06: Int 
    var no07: Int 
    var no08: Int 
    var no09: Int 
    var no10: Int 
    var no11: Int 
    var no12: Int 
    var no13: Int 
    var no14: Int 
    var no15: Int 
    var no16: Int 
    var no17: Int 
    var no18: Int 
    var no19: Int 
    var no20: Int 
    var no21: Int 
    var no22: Int 
    var no23: Int 
    var no24: Int 
    var no25: Int 
    var no26: Int 
    var no27: Int 
    var no28: Int 
    var no29: Int 
    var no30: Int 
    var no31: Int 
    var no32: Int 
    var no33: Int 
}

@Observable class StatisticFront4: Codable {
    enum CodingKeys: String, CodingKey {
        case _no04 = "no04"
        case _no05 = "no05"
        case _no06 = "no06"
        case _no07 = "no07"
        case _no08 = "no08"
        case _no09 = "no09"
        case _no10 = "no10"
        case _no11 = "no11"
        case _no12 = "no12"
        case _no13 = "no13"
        case _no14 = "no14"
        case _no15 = "no15"
        case _no16 = "no16"
        case _no17 = "no17"
        case _no18 = "no18"
        case _no19 = "no19"
        case _no20 = "no20"
        case _no21 = "no21"
        case _no22 = "no22"
        case _no23 = "no23"
        case _no24 = "no24"
        case _no25 = "no25"
        case _no26 = "no26"
        case _no27 = "no27"
        case _no28 = "no28"
        case _no29 = "no29"
        case _no30 = "no30"
        case _no31 = "no31"
        case _no32 = "no32"
        case _no33 = "no33"
        case _no34 = "no34"
    }
    var no04: Int
    var no05: Int 
    var no06: Int 
    var no07: Int 
    var no08: Int 
    var no09: Int 
    var no10: Int 
    var no11: Int 
    var no12: Int 
    var no13: Int 
    var no14: Int 
    var no15: Int 
    var no16: Int 
    var no17: Int 
    var no18: Int 
    var no19: Int 
    var no20: Int 
    var no21: Int 
    var no22: Int 
    var no23: Int 
    var no24: Int 
    var no25: Int 
    var no26: Int 
    var no27: Int 
    var no28: Int 
    var no29: Int 
    var no30: Int 
    var no31: Int 
    var no32: Int 
    var no33: Int 
    var no34: Int 
}

@Observable class StatisticFront5: Codable {
    enum CodingKeys: String, CodingKey {
        case _no06 = "no06"
        case _no07 = "no07"
        case _no08 = "no08"
        case _no09 = "no09"
        case _no10 = "no10"
        case _no11 = "no11"
        case _no12 = "no12"
        case _no13 = "no13"
        case _no14 = "no14"
        case _no15 = "no15"
        case _no16 = "no16"
        case _no17 = "no17"
        case _no18 = "no18"
        case _no19 = "no19"
        case _no20 = "no20"
        case _no21 = "no21"
        case _no22 = "no22"
        case _no23 = "no23"
        case _no24 = "no24"
        case _no25 = "no25"
        case _no26 = "no26"
        case _no27 = "no27"
        case _no28 = "no28"
        case _no29 = "no29"
        case _no30 = "no30"
        case _no31 = "no31"
        case _no32 = "no32"
        case _no33 = "no33"
        case _no34 = "no34"
        case _no35 = "no35"
    }
    var no06: Int
    var no07: Int 
    var no08: Int 
    var no09: Int 
    var no10: Int 
    var no11: Int 
    var no12: Int 
    var no13: Int 
    var no14: Int 
    var no15: Int 
    var no16: Int 
    var no17: Int 
    var no18: Int 
    var no19: Int 
    var no20: Int 
    var no21: Int 
    var no22: Int 
    var no23: Int 
    var no24: Int 
    var no25: Int 
    var no26: Int 
    var no27: Int 
    var no28: Int 
    var no29: Int 
    var no30: Int 
    var no31: Int 
    var no32: Int 
    var no33: Int 
    var no34: Int 
    var no35: Int 
}

@Observable class StatisticHind1: Codable {
    enum CodingKeys: String, CodingKey {
        case _no01 = "no01"
        case _no02 = "no02"
        case _no03 = "no03"
        case _no04 = "no04"
        case _no05 = "no05"
        case _no06 = "no06"
        case _no07 = "no07"
        case _no08 = "no08"
        case _no09 = "no09"
        case _no10 = "no10"
        case _no11 = "no11"
    }
    var no01: Int
    var no02: Int 
    var no03: Int 
    var no04: Int 
    var no05: Int 
    var no06: Int 
    var no07: Int 
    var no08: Int 
    var no09: Int 
    var no10: Int 
    var no11: Int 
}

@Observable class StatisticHind2: Codable {
    enum CodingKeys: String, CodingKey {
        case _no02 = "no02"
        case _no03 = "no03"
        case _no04 = "no04"
        case _no05 = "no05"
        case _no06 = "no06"
        case _no07 = "no07"
        case _no08 = "no08"
        case _no09 = "no09"
        case _no10 = "no10"
        case _no11 = "no11"
        case _no12 = "no12"
    }
    var no02: Int
    var no03: Int 
    var no04: Int 
    var no05: Int 
    var no06: Int 
    var no07: Int 
    var no08: Int 
    var no09: Int 
    var no10: Int 
    var no11: Int 
    var no12: Int 
}
